package com.shy.userservice.utils;

import java.util.Random;

/**
 * @author RinMi
 * @since 2022/11/23/5:13 PM
 */
public class PasswordGenerator {

    private final int passwordBit;

    public PasswordGenerator(int passwordBit){
        this.passwordBit = passwordBit;
    }

    public String generator(){
        String str = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789";
        int len = str.length();
        Random random = new Random();
        StringBuilder res = new StringBuilder();
        for (int i = 0; i < this.passwordBit; i++){
            res.append(str.charAt(random.nextInt(len)));
        }
        return res.toString();
    }

}
